<?php
	include($_SERVER['DOCUMENT_ROOT'].'/gourmet-express/trunk/src/class/mrp/recetas/FN/MrpRecetaFN.class.php');
	
	$o_MrpRecetaFN = new MrpRecetaFN();   
    if (isset($_REQUEST['txtRecetaId'])) $o_MrpRecetaFN->setRctRecetaId($_REQUEST['txtRecetaId']);
    if (isset($_REQUEST['txtDescripcion'])) $o_MrpRecetaFN->setRctDescripcion($_REQUEST['txtDescripcion']);
    


	$page = isset($_POST['page']) ? $_POST['page'] : 1;
	$rp = isset($_POST['rp']) ? $_POST['rp'] : 10;
	$sortname = isset($_POST['sortname']) ? $_POST['sortname'] : 'name';
	$sortorder = isset($_POST['sortorder']) ? $_POST['sortorder'] : 'desc';
	//$query = isset($_POST['query']) ? $_POST['query'] : false;
	//$qtype = isset($_POST['qtype']) ? $_POST['qtype'] : false;
	
	$o_MrpRecetaFN->page = $page;
	$o_MrpRecetaFN->tamPag = $rp;
	$o_MrpRecetaFN->sortCampos = $sortname;
	$o_MrpRecetaFN->sortType   = $sortorder;
    
	$o_MrpRecetaFN->setRctTipoProducto("PT");
                
	$o_rpta=$o_MrpRecetaFN->select();
	if(is_array($o_rpta))
	{
		header('Content-Type: application/json; Charset=UTF-8',true);
		//header("Content-Type: text/html;charset=utf-8");
		$jsonData = array('page'=>$page,'total'=>$o_MrpRecetaFN->numeroRegistros,'rows'=>array());
		foreach ($o_rpta as $key => $obj)
		{
		//If cell's elements have named keys, they must match column names
		//Only cell's with named keys and matching columns are order independent.
			$entry = array('id'=>$obj->getRctRecetaId(),
			    'cell'=>array(
			            'receta_Id' =>$obj->getRctRecetaId(),
			            'producto'=>$obj->getRctProductoId(),
			            'descripcion'=>utf8_encode($obj->getRctDescripcion()),
			            'detalles'=>utf8_encode($obj->getRctDetalles()),
			            'tipoProduc'=>$obj->getRctTipoProducto(),
			            'cantProdc'=>$obj->getRctProductoCant(),
			            'uomProdc'=>$obj->getRctProductoUoM(),
			            'opciones'=>"<img border='0' title='Detalle Receta' src='/gourmet-express/trunk/imgs/icons/application_view_list.png' onclick=fn_detalle('". $obj->getRctRecetaId()."') style='cursor:pointer;'><img border='0' title='Editar Orden' src='/gourmet-express/trunk/imgs/icons/page_edit.png' onclick=fn_editar('". $obj->getRctRecetaId()."') style='cursor:pointer;'><img border='0' title='Eliminar Orden' src='/gourmet-express/trunk/imgs/icons/delete_icon.png' onclick=fn_eliminar('". $obj->getRctRecetaId()."') style='cursor:pointer;'>"
			    ),
			);
			$jsonData['rows'][] = $entry;
		}
		echo json_encode($jsonData);
	}?>